﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Orchard.ContentManagement;
using Orchard;
using Orchard.Localization;
using Orchard.Data;
using Guang.UserGeolocation.Models;

namespace Guang.UserGeolocation.Controllers
{
    public class Save2DBController :Controller
    {
        private readonly IRepository<UserCoordinateRecord> _repository;        
        private readonly ITransactionManager _transactionManager;
        private readonly IContentManager _contentManager;
        public IOrchardServices Services { get; set; }
        public Localizer T { get; set; }
       

        public Save2DBController(
            IOrchardServices services,           
            IContentManager contentManager,
            ITransactionManager transactionManager,
            
            IRepository<UserCoordinateRecord> repository
            )
        {
            Services = services;            
            _contentManager = contentManager;
            T = NullLocalizer.Instance;

            _transactionManager = transactionManager;
            _repository = repository;
            

        }

       
        [HttpPost]
        public ActionResult Create(double latitude, double longitude)
        {
            var userGeo = new UserCoordinateRecord
            {
               // Id=100,
                Latitude = latitude,
                Longitude = longitude
            };
            _repository.Create(userGeo);         

            return null;
        }
    }
}